
#include "mainwindow.h"
#include <QApplication>
#include<stdlib.h>
#include <iostream>
#include<armadillo>

//#include "QNetWork.h"

#include <QHostAddress>
#include <QNetworkInterface>
#include <QHostInfo>
#include <QMessageBox>

#include <QTcpServer>
#include <QTcpSocket>
#include <QTextStream>
#include <QVBoxLayout>



int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

/**


    // 服务端启动
    Server server;
    server.startServer();

    // 客户端使用
    Client client;
    client.connectToServer("127.0.0.1", 12345);
    client.sendMessage("Hello Server!");
**/

    ////////////////////////////// info tcp ////////////////////////////////////
    QString localHostName = QHostInfo::localHostName();
        QHostInfo hostinfo = QHostInfo::fromName(localHostName);
        QList<QHostAddress> listAddress = hostinfo.addresses();
        if(!listAddress.isEmpty())
        {
            std::cout << listAddress.first().toString().toStdString() << std::endl;
        }
        QString detail="";
        QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();
        for(int i = 0 ; i < list.count() ; i++)
        {
                QNetworkInterface interfaces = list.at(i);
                detail=detail+("设备：")+interfaces.name()+"\n";
                detail=detail+("硬件地址：")+interfaces.hardwareAddress () +"\n";
                QList<QNetworkAddressEntry> entryList=interfaces.addressEntries();
                for(int j = 0;j<entryList.count();j++)
                 {
                    QNetworkAddressEntry entry=entryList.at(j);
                    detail=detail+"\t"+("IP 地址：") +entry.ip().toString() +"\n";
                    detail=detail+"\t"+("子网掩码：") +entry.netmask().toString ()+"\n";
                    detail=detail+"\t"+ ("广播地址：") +entry.broadcast().toString ()+"\n";
                }

        }
        QMessageBox::information(0, ("Detail1") , detail);


    ////////////////////////// juzhen graph ////////////////////////////////
    w.show();

    arma::mat A = arma::randu<arma::mat>(4,5);  // 创建一个4x5的随机矩阵
    arma::mat B = arma::randu<arma::mat>(4,5);  // 另一个4x5的随机矩阵
    arma::mat C = A + B;                        // 矩阵加法
    std::cout << "A + B = \n" << C << std::endl; // 输出结果
    return a.exec();
}
